﻿(function () {
    var count = $("#select_Type > li").length;
    $("#select_Type > li:lt(" + count + ")").each(function (i) {
        $(this).click(function () {
            $("#select_Type>li").attr("class", "");
            //alter(i);
            $(this).attr("class", "ac");
            var messageType = $(this).attr("messageType");
            ViewMessage(messageType, 1);
            $("#preview").hide();
        });
    });
})();
//(function () {
//    $(".options > li").each(function (i) {
//        $(this).click(function () {
//            var messageType = $(this).attr("messageType");
//             $("#messageType").val(messageType);
//            ViewMessage($("#hidChannelID").val(),$("#hidColumnID").val(),messageType, 1);
//            $(".selected").html($(this).html());
//            $('.options').removeClass('ac');
//            Ucenter.init();
//            Ucenter.bIndex.init();
//        });
//    });
//})();
function showPre() {
    var pageIndex = parseInt($("#PageIndex").val());
    if (pageIndex <= 2) {
        $("#preview").hide();
    }
    if (pageIndex >= 1) {
        $("#next").show();
    }
    ViewMessage($("#messageType").val(), pageIndex - 1);
}
function showNext() {
    var pageIndex = parseInt($("#PageIndex").val());
    if (pageIndex >= 9) {
        $("#next").hide();
    } else {
        ViewMessage($("#messageType").val(), pageIndex + 1);
        $("#preview").show();
    }
}
function CheckPage(retValue) {
    var curPage = parseInt($("#PageIndex").val());
    var content = retValue.split("$pager$")[0];
    if (curPage == 1) {
        $("#preview").hide();
    }
    if (retValue == "暂无数据" || retValue == "" || content == undefined) {
        $("#next").hide();
        $(".view_stack").html(retValue);
    } else {
        $(".view_stack").html(content);
        if (retValue.split("$pager$")[1] != undefined) {
            var allPage = parseInt(retValue.split("$pager$")[1]);
            if (allPage <= curPage) {
                $("#next").hide();
            } else {
                $("#next").show();
            }
        } else {
            var count = $(".view_stack > div").length;
            if (count >= 10 && curPage < 9) {
                $("#preview").show();
                $("#next").show();
            } else {
                $("#next").hide();
            }
            if (curPage == 1) {
                $("#preview").hide();
            } else {
                $("#preview").show();
            }
        }
    }
}
function SearchVideoByKeyWord(curPage) {
    //return '<div class="pub-messbox">数据请求错误！</div>';
    var keyWord = $("#searchInput").val();
    var html = "";
    $.getJSON("http://so.baomihua.com/interfaces/videoSeatch.aspx?jsoncallback=?", { keyword: keyWord, pagesize: 5, curpage: curPage }, function (json) {
        var allCount = parseInt(json.totalNum);
        var content = json.videoList;

        if (allCount == 0) {
            html = "已无数据";
        }
        if (content != undefined && content.length > 0) {
            for (var i = 0; i < content.length; i++) {
                html += PUBAjaxClass.GetHtmlByVideoId(curUserID, content[i].videoID).value;
                //html += '<div class="pub-messbox">数据请求错误！</div>';
            }
        }
                if (curPage == 1) {
                    $(".p-scrollLoad").html("");
                    $('.p-scrollLoad').html(html);
                }
                else {
                    $('.p-scrollLoad').append(html);
                }
        //Ucenter.bIndex.init();
    });
    //return html;

}
//转载视频
function ReprintedVedio(userID, objUserID, obj) {
    var retVal = PUBAjaxClass.LinkVideo(curUserID, obj).value;
    if (retVal == 1) {
        art.dialog({
            content: "视频转载成功！",
            skin: 'facebook',
            lock: false,
            effect: false,
            border: false
        }).follow("link_" + userID + "_" +obj).time(1);
        //alertMessage(1, '视频转载成功');
        $(".view_stack div span[videoID='" + obj + "']").hide();
    } else if (retVal == 2) {
        alertMessage(3, '该视频您已转载过了');
    } else if (retVal == 0) {
        alertMessage(2, '转载失败，可能由网络问题引起，请稍后操作!');
    } else if (retVal == -1) {
        alertMessage(2, '转载失败，可能由网络问题引起，请稍后操作!');
    } else if (retVal == -9) {
        alertMessage(2, '转载失败，不能转载自己的视频!');
    }
    //ViewMessage($("#messageType").val(), 1);
}

function CreatePage_V2(channelId, columnId, curPage) {
    $('.p-scrollLoad').html('<div class="pub-loading_s1" style="text-align:left;">数据加载中...</div>')
    $("#hidChannelID").val(channelId);
    $("#hidColumnID").val(columnId);
    $("#PageIndex").val(curPage);
    var tempHtml = PUBAjaxClass.GetVUserList(channelId, columnId, 14).value;
    if (tempHtml != "") {
        $(".vipUsers").show();
        $(".usersList").html(tempHtml);
        //Ucenter.bIndex.init($(tempHtml));
    } else {
        $(".vipUsers").hide();
    }
    //Ucenter.bIndex.init();
    ViewMessage(channelId, columnId, $("#messageType").val(), curPage);
}